package br.com.banco.control;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.banco.ContaBusiness;
import br.com.banco.entity.Conta;

/**
 * Servlet implementation class ConsultaSaldo
 */
public class ConsultaSaldo extends HttpServlet {

    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public ConsultaSaldo() {
        super();

    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    @Override
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    @Override
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        double saldo = new ContaBusiness((Conta) request.getAttribute("conta")).consultaSaldo();

        request.setAttribute("saldo", saldo);
        request.getRequestDispatcher("saldo.jsp").forward(request, response);
    }
}
